<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
       <jsp:include page="includes/script.html"/>
        <title>Comp Graph</title>
        <link href="css/init.css" rel="stylesheet" type="text/css">
    </head>

    <body>
        <center>
         <form method="get">


            From : <input type="text" value="${start}" name="start" readonly> <img src="images/calendar.gif" onclick="displayDatePicker('start', false, 'ymd', '-');" />&nbsp;
             To : <input type="text" value="${end}" name="end" readonly> <img src="images/calendar.gif" onclick="displayDatePicker('end', false, 'ymd', '-');" />&nbsp;
               <input  type="submit" name="submit" value="View" >

        </form>
        </center>
        <br>

        <center> <a href="comp-graph.png"><img src="comp-graph.png" width="800" border="0"></a></center>

        <c:if test='${not empty start}'>
            <c:set var="persenRjt" value="0" />
            <c:set var="cummInspPrice" value="0" />
            <c:set var="cummRjtPrice" value="0" />
            <c:set var="persenRjtCumm" value="0" />
        <br>
        <center>
        <table  width="1000">
            <tr>
                <td width="4%">Date</td>
                <c:forEach items="${data}" var="data">
                    <td width="3%" align="center"><fmt:formatDate pattern="d" value="${data.date}" /></td>
                </c:forEach>
            </tr>
            <tr>
                <td width="4%">Insp Pcs</td>
                <c:forEach items="${data}" var="data">
                    <td width="3%" align="center"><fmt:formatNumber value="${data.inspprice}" maxFractionDigits="1" /></td>
                </c:forEach>
            </tr>
            <tr>
                <td width="4%">Rjt Pcs</td>
                <c:forEach items="${data}" var="data">
                    <td width="3%" align="center"><fmt:formatNumber value="${data.rjtprice}" maxFractionDigits="1" /></td>
                </c:forEach>
            </tr
            <tr>
                <td width="4%">% Rjt</td>
                <c:forEach items="${data}" var="data">
                    <c:set var="persenRjt" value="${data.rjtprice / data.inspprice}" />
                    <td width="3%" align="center"><fmt:formatNumber value="${persenRjt * 100}" maxFractionDigits="1" /></td>
                </c:forEach>
            </tr>
            <tr>
                <td width="4%">Cumm Insp Pcs</td>

                <c:forEach items="${data}" var="data">
                    <c:set var="cummInspPrice" value="${cummInspPrice + data.inspprice}" />
                    <td width="3%" align="center"><fmt:formatNumber value="${cummInspPrice}" maxFractionDigits="1" /></td>
                </c:forEach>
            </tr>
            <tr>
                <td width="4%">Cumm Rjt Pcs</td>
                <c:forEach items="${data}" var="data">
                  <c:set var="cummRjtPrice" value="${cummRjtPrice + data.rjtprice}" />
                  <td width="3%" align="center"><fmt:formatNumber value="${cummRjtPrice}" maxFractionDigits="1" /></td>
                </c:forEach>
            </tr>

            <tr>
                <td width="4%">% Rjt (Cumm)</td>
                <c:forEach items="${data}" var="data">
                    <c:set var="cummInspPrice" value="${cummInspPrice + data.inspprice}" />
                     <c:set var="cummRjtPrice" value="${cummRjtPrice + data.rjtprice}" />
                     <c:set var="persenRjtCumm" value="${cummRjtPrice / cummInspPrice}" />

                    
                     <td width="3%" align="center"><fmt:formatNumber value="${persenRjtCumm * 100}" maxFractionDigits="1" /></td>
                </c:forEach>
            </tr>
        </table>
            </center>
        </c:if>



    </body>
</html>
